<?php

namespace Download\Controller;

use Think\Controller;

class IndexController extends Controller {
	public function index() {
		$platform = 1;
		if (strpos ( $_SERVER ['HTTP_USER_AGENT'], 'iPhone' ) || strpos ( $_SERVER ['HTTP_USER_AGENT'], 'iPad' )) {
			$platform = 2;
		} else if (strpos ( $_SERVER ['HTTP_USER_AGENT'], 'Android' )) {
			$platform = 1;
		}
		
		$lobbyInfo = M ( 'Lobbyinfo' );
		$lobbyData = $lobbyInfo->where ( "id='$platform'" )->find ();
		$name = $lobbyData['name'];
		$webUrl = $lobbyData ['web'];
		$date = $lobbyData ['updatedate'];
		$ver = $lobbyData ['ver'];
		
		$this->assign ( array (
				'projectname' => $name,
				'weburl' => $webUrl,
				'date' => $date,
				'apkurl' => C ( 'APK_URL' ),
				'ipaurl' => C ( 'IPA_URL' ),
				'version' => $ver 
		) );
		$this->display ();
	}
}